<template>
  <div class="posttable">
    <el-row>
      <el-col style="padding-right: 30px;padding-left: 60px;">
        <div class="addform addForm">
          <el-form :label-position="labelPosition" ref="form" :model="form" :rules="rules">
            <el-col class="infotitle">
              <p>基础信息</p>
            </el-col>
            <el-row class="change">
              <el-col :span="6">
                <el-form-item label="推送客户" prop="customerName" style="margin-bottom: 10px;">
                  <el-select v-model.trim="form.customerName" placeholder="请选择推送客户" @change="selectcustomer"
                             :disabled="disflag">
                    <el-option
                      v-for="item in customerNames"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="需求编号" prop="requireNum" style="margin-bottom: 10px;">
                  <el-select v-model.trim="form.requireNum" placeholder="请选择需求编号" @change="selposition"
                             :disabled="disflag">
                    <el-option
                      v-for="item in num"
                      :key="item"
                      :label="item"
                      :value="item">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="推送职位" prop="postName" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.postName" placeholder="请选择推送职位" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="职位级别" prop="postLevel" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.postLevel" placeholder="请选择职位级别" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="姓名" prop="name" style="margin-bottom: 10px;">
                  <el-input v-model="form.name" placeholder="请输入姓名" :disabled="disflag"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="性别" prop="sex" style="margin-bottom: 10px;">
                  <el-input v-model="form.sex" placeholder="请输入性别" :disabled="disflag"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="所属区域" prop="area" style="margin-bottom: 10px;">
                  <el-select v-model.trim="form.area" placeholder="请选择所属区域" :disabled="disflag">
                    <el-option
                      v-for="item in Areas"
                      :key="item"
                      :label="item"
                      :value="item">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="出生年月" prop="birthday" style="margin-bottom: 10px;">
                  <el-date-picker
                    :disabled="disflag"
                    v-model.trim="form.birthday"
                    format="yyyy-MM"
                    value-format="yyyy-MM"
                    type="month"
                    style="width: 274px;"
                    placeholder="请选择出生年月">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="毕业学校" prop="college" style="margin-bottom: 10px;">
                  <el-input v-model="form.college" placeholder="请输入毕业学校" :disabled="disflag"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="学历" prop="education" style="margin-bottom: 10px;">
                  <el-input v-if="resumeId" v-model="form.education" placeholder="请输入学历" disabled></el-input>
                  <el-select v-else v-model.trim="form.education" placeholder="请选择学历">
                    <el-option
                      v-for="item in education"
                      :key="item.value"
                      :label="item.value"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="专业" prop="speciality" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.speciality" placeholder="请输入专业" :disabled="disflag"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="毕业时间" prop="graduationTime" style="margin-bottom: 10px;">
                  <el-date-picker
                    :disabled="disflag"
                    v-model.trim="form.graduationTime"
                    format="yyyy-MM"
                    type="month"
                    style="width: 274px;"
                    value-format="yyyy-MM"
                    placeholder="请选择毕业时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="电话" prop="phone" style="margin-bottom: 10px;">
                  <el-input v-model="form.phone" placeholder="请输入电话" :disabled="disflag"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="邮箱" prop="mail" style="margin-bottom: 10px;">
                  <el-input v-model="form.mail" placeholder="请输入邮箱" :disabled="disflag"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="入职时间" prop="entryTime" style="margin-bottom: 10px;">
                  <el-input v-model="form.entryTime" :disabled="disflag" placeholder="请输入入职时间"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="工作关系" prop="workRelation" style="margin-bottom: 10px;">
                  <el-select v-model="form.workRelation" placeholder="请选择工作关系">
                    <el-option v-for="(item,index) in workrelationList" :key="index" :label="item.name"
                               :value="item.code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="工作性质" prop="worknature" style="margin-bottom: 10px;">
                  <el-select v-model="form.worknature" placeholder="请选择工作性质" @change="selectworknature">
                    <el-option v-for="(item,index) in worknatureList" :key="index" :label="item.name"
                               :value="item.code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="form.worknature == '1'">
                <el-form-item label="外包项目名称" prop="outsourceproject" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.outsourceproject" placeholder="请输入外包项目名称"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="form.worknature == '1'">
                <el-form-item label="外包岗位名称" prop="outsourceposition" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.outsourceposition" placeholder="请输入外包岗位名称"></el-input>
                </el-form-item>
              </el-col>
              
              <el-col class="infotitle">
                <p>招聘详情</p>
              </el-col>
              <el-col :span="6">
                <el-form-item label="招聘需求部门" prop="orgidsid" style="margin-bottom: 10px;">
                  <el-select v-model="form.orgidsid" placeholder="请选择部门" @change="selorgidsid">
                    <el-option v-for="(item,index) in OrgnameList"
                               :key="index"
                               :label="item.orgname"
                               :value="item.orgid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="负责人" prop="StaffNameid" style="margin-bottom: 10px;">
                  <el-select v-model="form.StaffNameid" placeholder="请选择负责人" @change="selStaffNameid">
                    <el-option v-for="(item,index) in StaffNameList"
                               :key="index"
                               :label="item.staffname"
                               :value="item.staffname">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="招聘需求id" prop="hrrectdemandid" style="margin-bottom: 10px;">
                  <el-select v-model="form.hrrectdemandid" placeholder="请选择招聘需求id" @change="selHrrectdemandid">
                    <el-option v-for="(item,index) in RemandList"
                               :key="index"
                               :label="item.name"
                               :value="item.code">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="form.hrrectdemandid">
                <el-form-item label="工作所在地" prop="workplace" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.workplace" placeholder="请输入工作所在地" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="form.hrrectdemandid">
                <el-form-item label="部门" prop="StaffNameid" style="margin-bottom: 10px;">
                  <el-select v-model="form.orgidsid" placeholder="请选择部门" disabled>
                    <el-option v-for="(item,index) in OrgnameList"
                               :key="index"
                               :label="item.orgname"
                               :value="item.orgid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="form.hrrectdemandid && form.saleorgid">
                <el-form-item label="二级部门" prop="StaffNameid" style="margin-bottom: 10px;">
                  <el-select v-model="form.saleorgid" placeholder="请选择二级部门" :disabled="form.worknature !== '1'">
                    <el-option v-for="(item,index) in childrenDepartlist"
                               :key="index"
                               :label="item.OrgName"
                               :value="item.OrgId">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="职位" prop="position" style="margin-bottom: 10px;">
                  <el-select v-model="form.position" placeholder="请选择职位" :disabled="form.worknature !== '1'">
                    <el-option v-for="(item,index) in positionList"
                               :key="index"
                               :label="item.name"
                               :value="item.code">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="招聘原因" prop="entryreason" style="margin-bottom: 10px;">
                  <el-select v-model="form.entryreason" placeholder="请选择招聘原因" :disabled="form.worknature !== '1'">
                    <el-option v-for="(item,index) in recreasonList"
                               :key="index"
                               :label="item.name"
                               :value="item.code">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="计划入职时间" prop="plannedentrytime" style="margin-bottom: 10px;">
                  <el-date-picker
                    width="137px"
                    v-model="form.plannedentrytime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    format="yyyy-MM-dd"
                    placeholder="请输入入职时间"
                  ></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="form.worknature == '1' && roletype">
                <el-form-item label="框架协议价" prop="TreatyPrice" style="margin-bottom: 10px;">
                  <el-input v-model="form.TreatyPrice" placeholder="请输入框架协议价">></el-input>
                </el-form-item>
              </el-col>
              
              <el-col class="infotitle">
                <p>拟录取待遇</p>
              </el-col>
              <el-col :span="6">
                <el-form-item label="薪资(元)" prop="salary" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.salary" placeholder="请输入薪资（至少1000）" @blur="salarychange"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="薪数(月)" prop="salaryNum" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.salaryNum" placeholder="请输入薪数（至少12）"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="试用期比例（%）" prop="percent" style="margin-bottom: 10px;">
                  <el-select v-model="form.percent" placeholder="请选择试用期比例" @change="percentchange">
                    <el-option label="0" value="0"></el-option>
                    <el-option label="80" value="80"></el-option>
                    <el-option label="90" value="90"></el-option>
                    <el-option label="100" value="100"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="税前试用期工资（元）" prop="tryingSalary" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.tryingSalary" placeholder="请输入税前试用期工资（元）"
                            @blur="tryingSalarychange"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="补助情况" prop="subsidies" style="margin-bottom: 10px;">
                  <el-select v-model="form.subsidies" placeholder="请选择补助情况" @change="selsubdidies">
                    <el-option v-for="(item,index) in subsidiesList" :key="index" :value="item.code"
                               :label="item.name"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="餐费补贴（元）" prop="mealSubsidy" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.mealSubsidy" placeholder="请输入餐费补贴（元）"
                            :disabled="subsidiesflag"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="话费补贴（元）" prop="telephoneSubsidy" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.telephoneSubsidy" placeholder="请输入话费补贴（元）"
                            :disabled="subsidiesflag"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="电脑补贴（元）" prop="computerSubsidy" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.computerSubsidy" placeholder="请输入电脑补贴（元）"
                            :disabled="subsidiesflag"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item
                  label="合同期（年）"
                  prop="year"
                  style="margin-bottom: 10px;"
                >
                  <el-input v-model.trim="form.year" placeholder="请输入合同期"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="试用期（月）" prop="month" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.month" placeholder="请输入试用期"></el-input>
                </el-form-item>
              </el-col>
              <el-col class="infotitle">
                <p>其他</p>
              </el-col>
              <el-col :span="6">
                <el-form-item label="社保缴纳地" prop="socialArea" style="margin-bottom: 10px;">
                  <el-select v-model="form.socialArea" placeholder="请选择社保缴纳地">
                    <el-option v-for="(item,index) in socialareaList" :key="index" :value="item.code"
                               :label="item.name"></el-option>
                  </el-select>
                  <!--                  <el-input v-model.trim="form.socialArea" placeholder="请输入社保缴纳地"></el-input>-->
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="简历推送部门" prop="pushOgnization" style="margin-bottom: 10px;">
                  <el-input v-model="form.pushOginization" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="简历来源" prop="resumeFrom" style="margin-bottom: 10px;">
                  <el-input v-model="form.resumeFrom" disabled v-if="resumeId"></el-input>
                  
                  <el-select v-else v-model.trim="form.resumeFrom" placeholder="请选择简历来源">
                    <el-option
                      v-for="(item,index) in originlist"
                      :key="index"
                      :label="item.name"
                      :value="item.name">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              
              <el-col v-if="!resumeId">
                <el-form-item style="margin-bottom: 10px;">
                  <div style="max-width:32rem;margin-top: 10px;">
                    <el-upload
                      class="upload-demo"
                      ref="upload"
                      type="file"
                      :action="actionurl"
                      :before-upload="beforeupload"
                      :show-file-list="true"
                      :file-list="fileList"
                      :on-success="handleAvatarSuccess"
                      :on-remove="handleRemove"
                      :limit="2"
                      accept=".pdf,.docx,.doc"
                    >
                      <el-button class="upload" slot="trigger">选取中文文件</el-button>
                      <!--                      :on-change="handleChange"-->
                    </el-upload>
                  </div>
                </el-form-item>
                <el-col style="margin-bottom: 30px;">
                  <div v-if="!filetype"
                       style="color: #F56C6C;color: #F56C6C;font-size: 12px;line-height: 1;padding-top: 4px;">
                    文件上传格式为pdf、docx、doc。
                  </div>
                  <div v-if="selectfile"
                       style="color: #F56C6C;color: #F56C6C;font-size: 12px;line-height: 1;padding-top: 4px;">请上传简历!
                  </div>
                </el-col>
              </el-col>
              
              <el-col>
                <el-form-item>
                  <el-button class="save" :disabled="senddis" @click="submitForm('form')">转HR</el-button>
                  <el-button class="cancel" @click="cancel('form')">取消</el-button>
                </el-form-item>
              </el-col>
            
            </el-row>
          </el-form>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import axios from 'axios'
  import qs from 'qs'
  
  export default {
    name: 'addresume',
    props: {
      resumeId: {
        type: String
      }
    },
    data() {
      var checkSalaryNum = (rule, value, callback) => {
        if (value < 12) {
          callback(new Error('请输入大于等于12的数字'));
        } else {
          callback()
        }
      };
      return {
        labelPosition: "top",
        form: {
          customerName: '',
          requireNum: '',
          postName: '',
          postLevel: '',
          name: '',
          college: '',
          education: '',
          speciality: '',
          graduationTime: '',
          sex: '男',
          area: '',
          birthday: '',
          phone: '',
          mail: '',
          entryTime: '',
          resumeFrom: "",
          salary: '',
          salaryNum: '',
          creater: '',
          pushOginization: '',
          TreatyPrice: '',
          percent: '',
          tryingSalary: '',
          mealSubsidy: '',
          computerSubsidy: '',
          telephoneSubsidy: '',
          year: '',
          month: '',
          socialArea: '',
          workRelation: '',
          worknature: '',
          outsourceproject: '',
          outsourceposition: '',
          orgidsid: '',
          StaffNameid: '',
          hrrectdemandid: '',
          position: '',
          entryreason: '',
          saleorgid: '',
          workplace: '',
          subsidies: '',
          plannedentrytime: '',
          fileName: '',
          path: '',
          fileAddress: '',
          suffix: '',
          group: ''
        },
        customerNames: [],
        num: [],
        Areas: [],
        originlist: [],
        education: [
          {
            value: '大专'
          }, {
            value: '本科'
          }, {
            value: '硕士'
          }, {
            value: '博士'
          }
        ],
        senddis: false,
        rules: {
          customerName: [
            {required: true, message: '请选择推送客户', trigger: 'change'}
          ],
          postName: [
            {required: true, message: '请选择推送职位', trigger: 'change'}
          ],
          postLevel: [
            {required: true, message: '请选择职位级别', trigger: 'change'}
          ],
          requireNum: [
            {required: true, message: '请选择需求编号', trigger: 'change'}
          ],
          sex: [
            {required: true, message: '请输入性别', trigger: 'blur'}
          ],
          name: [
            {required: true, message: '请输入姓名', trigger: 'blur'}
          ],
          speciality: [
            {required: true, message: '请输入专业', trigger: 'blur'}
          ],
          graduationTime: [
            {required: true, message: '请选择毕业时间', trigger: 'change'}
          ],
          area: [
            {required: true, message: '请选择所属区域', trigger: 'change'}
          ],
          education: [
            {required: true, message: '请输入学历', trigger: 'blur'}
          ],
          college: [
            {required: true, message: '请输入毕业院校', trigger: 'blur'}
          ],
          birthday: [
            {required: true, message: '请选择出生年月', trigger: 'change'}
          ],
          phone: [
            {required: true, message: '请输入联系方式', trigger: 'blur'},
            {
              pattern: /(^0\d{2,4}\-\d{7,8}$)|(^1[3|4|5|6|7|8|9][0-9]{9}$)/, message: '请输入正确的联系方式', trigger: 'blur'
            }
          ],
          mail: [
            {required: true, message: '请输入邮箱', trigger: 'blur'},
            {
              pattern: /^[A-Za-z\d]+(([-_.]*)+[A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/,
              message: '请输入正确的邮箱',
              trigger: 'blur'
            }
          ],
          entryTime: [
            {required: true, message: '请输入入职时间', trigger: 'blur'}
          ],
          resumeFrom: [
            {required: true, message: '请输入简历来源', trigger: 'blur'}
          ],
          creater: [
            {required: true, message: '请输入创建人', trigger: 'blur'}
          ],
          pushOginization: [
            {required: true, message: '请输入简历推送部门', trigger: 'blur'}
          ],
          TreatyPrice: [
            {required: true, message: '请输入框架协议价', trigger: 'blur'},
            {pattern: /^[1-9]\d*$/, message: '框架协议价为正整数', trigger: 'blur'}
          ],
          salary: [
            {required: true, message: '请输入薪资', trigger: 'blur'},
            {pattern: /^[1-9]+(\d{3,})+(\.[0-9]{1,2})?$/, message: '薪资为大于1000的数字', trigger: 'blur'}
          ],
          salaryNum: [
            {required: true, message: '请输入薪数', trigger: 'blur'},
            {pattern: /^[1-9]\d*$/, message: '薪数为正整数', trigger: 'blur'},
            {validator: checkSalaryNum, trigger: 'blur'}
          ],
          percent: [
            {required: true, message: '请选择试用期比例', trigger: 'change'}
          ],
          tryingSalary: [
            {required: true, message: '请输入税前试用期工资', trigger: 'blur'},
            {pattern: /^[1-9]+(\d{3,})+(\.[0-9]{1,2})?$/, message: '税前试用期工资为大于1000的数字', trigger: 'blur'}
          ],
          mealSubsidy: [
            {required: true, message: '请输入餐费补贴', trigger: 'blur'},
            {pattern: /^[1-9]\d*$/, message: '餐费补贴为正整数', trigger: 'blur'}
          ],
          telephoneSubsidy: [
            {required: true, message: '请输入话费补贴', trigger: 'blur'},
            {pattern: /^[1-9]\d*$/, message: '话费补贴为正整数', trigger: 'blur'}
          ],
          computerSubsidy: [
            // {pattern: /^[1-9]\d*$/, message: '电脑补贴为正整数', trigger: 'blur'}
          ],
          year: [
            {pattern: /^[+]{0,1}(\d+)$/, message: '合同期为正整数', trigger: 'blur'}
          ],
          month: [
            {pattern: /^[+]{0,1}(\d+)$/, message: '试用期为正整数', trigger: 'change'}
          ],
          socialArea: [
            {required: true, message: '请选择社保缴纳地', trigger: 'change'}
          ],
          workRelation: [
            {required: true, message: '请选择工作关系', trigger: 'change'}
          ],
          worknature: [
            {required: true, message: '请选择工作性质', trigger: 'change'}
          ],
          orgidsid: [
            {required: true, message: '请选择部门', trigger: 'change'}
          ],
          StaffNameid: [
            {required: true, message: '请选择负责人', trigger: 'change'}
          ],
          hrrectdemandid: [
            {required: true, message: '请选择招聘需求id', trigger: 'change'}
          ],
          saleorgid: [
            {required: true, message: '请选择二级部门', trigger: 'change'}
          ],
          subsidies: [
            {required: true, message: '请选择补贴情况', trigger: 'change'}
          ],
          entryreason: [
            {required: true, message: '请选择招聘原因', trigger: 'change'}
          ],
          plannedentrytime: [
            {required: true, message: '请选择计划入职时间', trigger: 'change'}
          ],
          position: [
            {required: true, message: '请选择职位', trigger: 'change'}
          ],
          outsourceproject: [
            {required: true, message: '请填写项目名称', trigger: 'blur'}
          ],
          outsourceposition: [
            {required: true, message: '请填写岗位名称', trigger: 'blur'}
          ],
          workplace: [
            {required: true, message: '请填写工作所在地', trigger: 'blur'}
          ],
        },
        disflag: false,
        actionurl: null,
        fileList: [],
        file: {},
        filetype: true,
        selectfile: false,
        OrgnameList: [],
        StaffNameList: [],
        RemandList: [],
        childrenDepartlist: [],
        positionList: [],
        recreasonList: [],
        workrelationList: [],
        worknatureList: [],
        subsidiesList: [],
        subsidiesflag: false,
        socialareaList: [],
        roletype : false
      }
    },
    created() {
      this.actionurl = this.url + "/statistics/entryInfo/upload";
      
      
      axios.post(this.url + '/resumeUpload/getHrCustomerNames').then(res => {
        this.unlogin(res.data.code)
        if (res.data.code == 200) {
          this.customerNames = res.data.data;
        }
      });
      
      axios.post(this.url + '/entry/apply/isAssistant').then(res => {
        this.roletype = res.data;
      });
      
      axios.get(this.url + "/demand/getAreas").then(res => {
        this.unlogin(res.data.code);
        if (res.data.code == 200) {
          this.Areas = res.data.data;
        }
      });
      //获取招聘需求部门的下拉框列表数据
      axios.post("ehruploadfile/RecruitmentToEhr/getOrgnameList").then(res => {
        if (res.data.code == 0) {
          this.OrgnameList = res.data.data.list;
        }
      });
      //获取工作关系下拉框列表数据
      axios.post('ehruploadfile/RecruitmentToEhr/findDropList', qs.stringify({
          moduleName: 'sysBase',
          methodName: 'findDropList',
          code: 'WorkingRelationship',
          optionDis: ''
        })
      ).then(res => {
        this.workrelationList = res.data;
      })
      //获取工作性质下拉框列表数据
      axios.post('ehruploadfile/RecruitmentToEhr/findDropList', qs.stringify({
          moduleName: 'sysBase',
          methodName: 'findDropList',
          code: 'WorkNature',
          optionDis: ''
        })
      ).then(res => {
        this.worknatureList = res.data;
      })
      //获取补助情况下拉框列表数据
      axios.post('ehruploadfile/RecruitmentToEhr/findDropList', qs.stringify({
          moduleName: 'sysBase',
          methodName: 'findDropList',
          code: 'Subsidies',
          optionDis: ''
        })
      ).then(res => {
        this.subsidiesList = res.data;
      })
      //获取社保缴纳地下拉框列表数据
      axios.post('ehruploadfile/RecruitmentToEhr/findDropList', qs.stringify({
          moduleName: 'sysBase',
          methodName: 'findDropList',
          code: 'SocialSecurityPayment',
          optionDis: ''
        })
      ).then(res => {
        this.socialareaList = res.data;
      })
      //获取简历来源下拉框列表数据
      axios.post('ehruploadfile/RecruitmentToEhr/findDropList', qs.stringify({
          moduleName: 'sysBase',
          methodName: 'findDropList',
          code: 'ResumeSource',
          optionDis: ''
        })
      ).then(res => {
        this.originlist = res.data;
      })
      
      if (this.resumeId) {
        this.disflag = true;
        axios.post(this.url + "/resumeUpload/getDetailById", qs.stringify({
          id: this.resumeId
        })).then(res => {
          this.unlogin(res.data.code)
          if (res.data.code == 200) {
            this.form.name = res.data.data.name;
            this.form.sex = res.data.data.sex;
            this.form.college = res.data.data.college;
            this.form.education = res.data.data.education;
            this.form.phone = res.data.data.phone;
            this.form.mail = res.data.data.mail;
            this.form.entryTime = res.data.data.entryTime;
            this.form.resumeFrom = res.data.data.origin;
            
            this.form.customerName = res.data.data.customerName;
            this.form.requireNum = res.data.data.requireNum;
            this.form.postName = res.data.data.postName;
            this.form.postLevel = res.data.data.postLevel;
            this.form.area = res.data.data.area;
            this.form.speciality = res.data.data.speciality;
            this.form.graduationTime = res.data.data.graduationTime;
            this.form.birthday = res.data.data.birthday;
            
            this.form.pushOginization = "南通招聘组";
          }
        })
      } else {
        this.disflag = false;
        this.$nextTick(() => {
          this.$refs.form.resetFields();
        })
        
        this.form.pushOginization = "南通招聘组";
      }
    },
    methods: {
      //补助情况的判断
      selsubdidies() {
        //补助情况为公司补助
        if (this.form.subsidies == '1') {
          this.subsidiesflag = true;
          this.form.mealSubsidy = '10';
          this.form.telephoneSubsidy = '200';
          this.form.computerSubsidy = '100';
        } else {
          //补助情况为其他种类时自定义
          this.subsidiesflag = false;
          this.form.mealSubsidy = '';
          this.form.telephoneSubsidy = '';
          this.form.computerSubsidy = '';
        }
      },
      //选择招聘需求部门的事件
      selorgidsid() {
        this.form.StaffNameid = '';
        this.form.hrrectdemandid = '';
        this.form.position = '';
        this.form.entryreason = '';
        this.form.saleorgid = '';
        this.form.workplace = '';
        //获取负责人下拉框列表数据
        axios.post('ehruploadfile/RecruitmentToEhr/getStaffNameListByOrgid', qs.stringify(
          {
            orgid: this.form.orgidsid
          }
          )
        ).then(res => {
          if (res.data.code == 0) {
            this.StaffNameList = res.data.data.list;
          }
        });
        
        //获取招聘原因下拉框列表数据
        axios.post('ehruploadfile/RecruitmentToEhr/findDropList', qs.stringify({
            moduleName: 'sysBase',
            methodName: 'findDropList',
            code: 'recruitReason',
            optionDis: ''
          })
        ).then(res => {
          this.recreasonList = res.data;
        })
      },
      //选择负责人的事件
      selStaffNameid() {
        this.form.hrrectdemandid = '';
        this.form.position = '';
        this.form.entryreason = '';
        this.form.saleorgid = '';
        this.form.workplace = '';
        axios.post('ehruploadfile/RecruitmentToEhr/getRemandListByid', qs.stringify({
          orgid: this.form.orgidsid,
          staffname: this.form.StaffNameid
        })).then(res => {
          if (res.data.code == 0) {
            this.RemandList = res.data.data.list;
          }
        })
      },
      //选择招聘需求id的事件
      selHrrectdemandid() {
        this.form.position = '';
        this.form.entryreason = '';
        this.form.saleorgid = '';
        this.form.workplace = '';
        //获取部分详细信息
        axios.post('ehruploadfile/RecruitmentToEhr/getHrRemandData', qs.stringify({
          code: this.form.hrrectdemandid
        })).then(res => {
          if (res.data.code == 0) {
            var data = res.data.data.hrRectDemand
            this.form.workplace = data.workplace;
            this.form.saleorgid = data.saleorgid;
            this.form.position = data.jobposition;
            this.form.entryreason = data.recreason;
          }
        })
        //二级部门的下拉框列表数据
        axios.post('ehruploadfile/RecruitmentToEhr/getChildrenDepart', qs.stringify({
          code: this.form.hrrectdemandid
        })).then(res => {
          if (res.data.code == 0) {
            this.childrenDepartlist = res.data.data.list;
          }
        })
        //获取职位的下拉框列表数据
        axios.post('ehruploadfile/RecruitmentToEhr/getPostion', qs.stringify({
          orgid: this.form.orgidsid
        })).then(res => {
          if (res.data.code == 0) {
            this.positionList = res.data.data.posList;
          }
        })
      },
      //切换外包和内部的工作性质
      selectworknature() {
        this.form.orgidsid = '';
        this.form.outsourceproject = '';
        this.form.outsourceposition = '';
        this.form.TreatyPrice = '';
        this.form.StaffNameid = '';
        this.form.hrrectdemandid = '';
        this.form.position = '';
        this.form.entryreason = '';
        this.form.saleorgid = '';
        this.form.workplace = '';
      },
      beforeupload(file) {
        this.file = {};
        this.file = file;
        this.selectfile = false;
        var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1);
        this.filetype = ((testmsg == 'docx') || (testmsg == 'pdf') || (testmsg == 'doc'));
        
        if (this.filetype) {
          this.file = file;
          this.fileList = [];
          this.fileList.push(this.file);
        }
        
        return (this.filetype)
      },
      handleRemove(file, fileList) {
        this.file = {};
        this.fileList = [];
        this.form.fileName = '';
        this.form.path = '';
        this.form.fileAddress = '';
        this.form.suffix = '';
        this.form.group = '';
      },
      handleAvatarSuccess(res, file) {
        this.form.fileName = res.data.fileName;
        this.form.path = res.data.path;
        this.form.fileAddress = res.data.fileAddress;
        this.form.suffix = res.data.suffix;
        this.form.group = res.data.group;
      },
      //获取需求编号的下拉框数据
      selectcustomer() {
        this.form.postName = '';
        this.form.requireNum = '';
        this.form.postLevel = '';
        axios.post(this.url + '/resumeUpload/getNoByCustomerName', qs.stringify({
          customerName: this.form.customerName
        })).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.num = res.data.data
          }
        });
      },
      //获取职位名称和职位级别
      selposition() {
        this.form.postLevel = '';
        this.form.postName = '';
        axios.post(this.url + '/resumeUpload/getPostNameByCustomerId', qs.stringify({
          no: this.form.requireNum
        })).then(res => {
          this.unlogin(res.data.code)
          if (res.data.code == 200) {
            this.form.postName = res.data.data;
          }
        });
        axios.post(this.url + '/resumeUpload/getPostLevelByNameAndCustomerId', qs.stringify({
          no: this.form.requireNum
        })).then(res => {
          this.unlogin(res.data.code)
          if (res.data.code == 200) {
            this.form.postLevel = res.data.data;
          }
        })
      },
      submitForm(formName) {
        if (!this.resumeId) {
          if (this.file.name == undefined) {
            this.selectfile = true;
          } else {
            this.selectfile = false;
          }
        }
        this.$refs[formName].validate((valid) => {
          if (valid && !this.selectfile && this.filetype) {
            this.senddis = true;
            this.form.resumeId = this.resumeId;
            axios.post(this.url + "/entry/apply/clientHRSystem", this.form).then(res => {
              this.unlogin(res.data.code)
              if (res.data.code == 200) {
                this.$refs[formName].resetFields();
                this.$emit("getData")
              }
            })
          }
        })
      },
      cancel(formName) {
        this.senddis = false;
        this.selectfile = false;
        this.filetype = true;
        this.$refs[formName].resetFields();
        this.$emit('getData');
      },
      //试用期比例的change事件
      percentchange() {
        var reg = /^[1-9]+(\d{3,})+(\.[0-9]{1,2})?$/;
        if (this.form.salary && reg.test(this.form.salary)) {
          var probationsalary = this.form.percent / 100;
          var data = this.form.salary * probationsalary;
          this.form.tryingSalary = String(Math.round(data * 100) / 100);
          this.$refs.form.validateField('tryingSalary');
        }
      },
      //薪资的blur事件
      salarychange() {
        var reg = /^[1-9]+(\d{3,})+(\.[0-9]{1,2})?$/;
        if (this.form.percent && reg.test(this.form.salary)) {
          var probationsalary = this.form.percent / 100;
          var data = this.form.salary * probationsalary;
          this.form.tryingSalary = String(Math.round(data * 100) / 100);
          this.$refs.form.validateField('tryingSalary');
        }
      },
      //税前试用期工资的blur事件
      tryingSalarychange() {
        var reg = /^[1-9]+(\d{3,})+(\.[0-9]{1,2})?$/;
        if (this.form.percent && reg.test(this.form.tryingSalary)) {
          var probationsalary = this.form.percent / 100;
          var data = this.form.tryingSalary / probationsalary;
          this.form.salary = String(Math.round(data * 100) / 100);
          this.$refs.form.validateField('salary');
        }
      },
    }
  }
</script>
<style scoped>
  .addform {
    color: #333 !important;
  }
  
  .storage {
    width: 150px;
    height: 40px;
    font-size: 16px;
    color: #4e72f3;
    border-radius: 4px;
    margin-right: 43px;
    border-color: #4e72f3;
  }
  
  .save {
    width: 150px;
    height: 40px;
    font-size: 16px;
    color: #fff;
    border-radius: 4px;
    margin-right: 43px;
    background: linear-gradient(to bottom, #5696f8 0%, #4e6ef5 100%);
    margin-top: 20px;
  }
  
  .cancel {
    width: 150px;
    height: 40px;
    border: 1px solid #4e6ef5;
    font-size: 16px;
    font-weight: 500;
    color: #4e6ef5;
  }
  
  .upload {
    width: 194px;
    height: 44px;
    margin-top: 10px;
    /*margin-bottom: 30px;*/
  }
  
  
  .infotitle {
    font-size: 20px;
    margin: 8px 0px 0px -30px;
    color: dodgerblue;
  }
</style>
